package com.uni.dto;

import java.util.Date;
import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.uni.common.util.SystemConfig;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 店铺
 * @author yuyanzheng
 *
 */
@NoArgsConstructor
@Data
public class ShopDTO {
	private Long id;
	private Long userId;
	private String name;
	private String phone;
	private String coverUrl;
	private Integer startingPrice;
	private String longitude;
	private String latitude;
	private Long schoolId;
	private Integer status;
	private String star;
	private Integer deleted;
	private Integer distance;
	private String deliveryTime;
	private Integer shippingFee;
	private Date updateTime;
	private Date createTime;
	private List<ShopCommodityDTO> shopCommoditys;
	
	public String getCoverUrlAll() {
		if(StringUtils.isNotBlank(coverUrl) && !coverUrl.startsWith("http")) {
			return SystemConfig.basePath + coverUrl;
		}
		return coverUrl;
	}
	
	public String getDeliveryTime() {
		if(distance == null || distance <= 1000) {
			return "30";
		}
		//TODO 计算配送时间
		return "40"; 
	}
}
